class broker {
	#This ensures that broker files exists.

	package { "ourgrid-broker":
		ensure => installed,
	}

	file { "/etc/ourgrid/broker.properties":
		ensure => present
	}	

	file { "/etc/ourgrid/log4j.cfg.xml":
		ensure => present,
		source => "puppet:///puppet-ourgrid/log4j.cfg.xml"
	}

	augeas {"broker.properties":
		context => "/etc/ourgrid",
		changes => [
			"set commune.fd.localhost.detectiontime $detectiontime",
			"set commune.filetransfer.notify.progress $notifyprogress",
			"set commune.xmpp.servername $servername",
			"set commune.xmpp.username $username",
			"set commune.xmpp.serverport $serverport",
			"set commune.filetransfer.timeout $timeout",
			"set commune.xmpp.password $passwd",
			"set commune.filetransfer.max.simultaneous $maxsimultaneous",
			"set commune.publickey $publickey",
			"set commune.fd.lan.heartbeatdelay $lanheartbeat",
			"set commune.xmpp.serversecureport $serversecureport",
			"set commune.fd.wan.heartbeatdelay $wanheartbeat",
			"set commune.fd.lan.detectiontime $landetectiontime",
			"set commune.fd.wan.detectiontime $wandetectiontime",
			"set commune.usemonitor $usemonitor",
			"set commune.fd.localhost.heartbeatdelay $localhostheartbeat",
			"set commune.privatekey $privatekey"
		]
	}

}

class peer {
	#This ensures that broker files exists.

	package { "ourgrid-peer":
		ensure => installed,
	}

	file { "/etc/ourgrid/peer.properties":
		ensure => present
	}	

	file { "/etc/ourgrid/log4j.cfg.xml":
		ensure => present,
		source => "puppet:///puppet-ourgrid/log4j.cfg.xml"
	}

	augeas {"peer.properties":
		context => "/etc/ourgrid",
		changes => [
			"set peer.accounting.cpuunit $cpuunit",
			"set peer.longitude $longitude",
			"set peer.description $description",
			"set peer.joincommunity $joincommunity",
			"set peer.latitude $latitude",
			"set peer.interval.saving $intervalsaving",
			"set peer.accounting.dataunit $dataunit",
			"set peer.repeatrequest $repeatrequest",
			"clear peer.label $label",
			"clear peer.default.sdf $sdf",
			"clear peer.email $email",
			"set peer.ds.network $network",
			"set peer.ds.update $update",
			"set confdir $confdir",
			"clear commune.publickey $publickey",
			"clear commune.privatekey $privatekey",
			"clear commune.xmpp.username $username",
			"clear commune.xmpp.password $password",
			"clear commune.xmpp.servername $servername",
			"set peer.requesting.cacertificate.path $requestingcertpath",
			"set peer.receiving.cacertificate.path $receivingcertpath",
		]
	}

}
